package com.dji.djiapp.websocket;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class JWebSocketClientReceiver extends BroadcastReceiver {
    private String TAG = "JWebSocketClientReceiver";
    public interface onReceiveListener{
        void onMessage(String message);
    }

    private onReceiveListener receiveListener;

    public JWebSocketClientReceiver(onReceiveListener receiveListener) {
        this.receiveListener = receiveListener;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String message = intent.getStringExtra("message");
        Log.i(TAG, message);
        if (receiveListener != null){
            receiveListener.onMessage(message);
        }
    }
}
